package com.briup.cms.dao;

import com.briup.cms.bean.Privilege;
import com.briup.cms.bean.extend.PrivilegeExtend;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface PrivilegeMapper {

    @Results({
            @Result(column = "is_hidden",property = "isHidden"),
            @Result(column = "parent_id",property = "parentId")
    })

    @Select("select a.*,b.name as parentName from cms_privilege a , cms_privilege b where a.parent_id = b.id")
    List<PrivilegeExtend> selectEx();

    @Select("select * from cms_privilege")
    List<Privilege> selectAll();

    @Select("select * from cms_privilege where name=#{#name}")
    List<Privilege> selectInNm(String Name);

    @Insert("insert into cms_privilege values(null,#{name},#{icon},#{type},#{path},#{isHidden},#{introduce},#{parentId})")
    void insert(Privilege privilege);

    @Update("update cms_privilege set name=#{name},icon=#{icon},type=#{type},path=#{path},is_hidden=#{isHidden},introduce=#{introduce},parent_id=#{parentId} where id=#{id}")
    void change(Privilege privilege);

    @Delete("delete from cms_privilege where id=#{id}")
    void delete(Long id);
}
